﻿




using System.Web.Mvc;
using Hotpot.Infrastructure;
using Hotpot.Models;
using Hotpot.Modules.Search.Models;
using Hotpot.Modules.Search.Services;
using Hotpot.ViewModels;

namespace Hotpot.Modules.Search.Controllers
{
    public class SearchController : Controller
    {
        private readonly ISearchResultService searchPostService;

        public SearchController(ISearchResultService searchPostService)
        {
            this.searchPostService = searchPostService;
        }

        public HotpotViewModelItems<ISearchResult> List(PagingInfo pagingInfo, SearchCriteria criteria)
        {
            IPageOfItems<ISearchResult> searchResults = criteria.HasCriteria() ? searchPostService.GetSearchResults(pagingInfo, criteria) : null;

            return new HotpotViewModelItems<ISearchResult>(searchResults) { Container = new SearchPageContainer() };
        }
    }
}
